package com.github.catvod.spider.merge;

import com.github.catvod.spider.merge.iC;

/* loaded from: classes.dex */
public class bY {
    public static void V0(aC aCVar, fa faVar) {
        fa faVar2 = faVar;
        int i = 0;
        while (faVar2 != null) {
            fa f = faVar2.f();
            aCVar.V0(faVar2, i);
            if (f != null && !faVar2.PD()) {
                faVar2 = f.W(faVar2.hr());
            }
            if (faVar2.u() > 0) {
                faVar2 = faVar2.W(0);
                i++;
            } else {
                while (faVar2.GM() == null && i > 0) {
                    aCVar.h(faVar2, i);
                    faVar2 = faVar2.f();
                    i--;
                }
                aCVar.h(faVar2, i);
                if (faVar2 == faVar) {
                    return;
                } else {
                    faVar2 = faVar2.GM();
                }
            }
        }
    }

    public static iC.Tw h(iC iCVar, fa faVar) {
        fa faVar2 = faVar;
        int i = 0;
        while (faVar2 != null) {
            iC.Tw V0 = iCVar.V0(faVar2, i);
            if (V0 == iC.Tw.STOP) {
                return V0;
            }
            if (V0 != iC.Tw.CONTINUE || faVar2.u() <= 0) {
                while (faVar2.GM() == null && i > 0) {
                    iC.Tw tw = iC.Tw.CONTINUE;
                    if ((V0 == tw || V0 == iC.Tw.SKIP_CHILDREN) && (V0 = iCVar.h(faVar2, i)) == iC.Tw.STOP) {
                        return V0;
                    }
                    fa f = faVar2.f();
                    i--;
                    if (V0 == iC.Tw.REMOVE) {
                        faVar2.nf();
                    }
                    V0 = tw;
                    faVar2 = f;
                }
                if ((V0 == iC.Tw.CONTINUE || V0 == iC.Tw.SKIP_CHILDREN) && (V0 = iCVar.h(faVar2, i)) == iC.Tw.STOP) {
                    return V0;
                }
                if (faVar2 == faVar) {
                    return V0;
                }
                fa GM = faVar2.GM();
                if (V0 == iC.Tw.REMOVE) {
                    faVar2.nf();
                }
                faVar2 = GM;
            } else {
                faVar2 = faVar2.W(0);
                i++;
            }
        }
        return iC.Tw.CONTINUE;
    }
}
